<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>

var a = 10;
function foo(){
    var a = 20;
    console.log(a);
    console.log(window.a);
}
foo()
</script>
</body>
</html>